package cn.chencq.page;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class PageParam implements Serializable {

	/**
	  * 
	  */
	private static final long serialVersionUID = 6297178964005032338L;

	/**
	 * 默认为第一页.
	 */
	public static final int DEFAULT_PAGE_NUM = 1;

	/**
	 * 默认每页记录数(15).
	 */
	public static final int DEFAULT_NUM_PER_PAGE = 10;

	/**
	 * 最大每页记录数(100).
	 */
	public static final int MAX_PAGE_SIZE = 1000;

	private int pageNum = DEFAULT_PAGE_NUM; // 当前页数

	private int pageSize = DEFAULT_NUM_PER_PAGE; // 每页记录数

	private String sidx; // 需要排序的字段名称

	private String order = "asc";// 排序方式
	/**
	 * 请求参数
	 */
	private Map<String, Object> params = new HashMap<String, Object>();

	/**
	 * 默认构造函数
	 */
	public PageParam() {
	}

	/**
	 * 带参数的构造函数
	 * 
	 * @param pageNum
	 * @param pageSzie
	 */
	public PageParam(int pageNum, int pageSize) {
		this.pageNum = pageNum;
		this.pageSize = pageSize;
	}
	
	public PageParam(int pageNum, int pageSize, String sidx, String order) {
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.sidx = sidx;
		this.order = order;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	/** 每页记录数 */
	public int getPageSize() {
		return pageSize > 0 ? pageSize : DEFAULT_NUM_PER_PAGE;
	}

	/** 每页记录数 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

}
